package top.ezzz.model;


import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import top.ezzz.db.DbProcessInfo;

@Setter
@Getter
@Accessors(chain = true)
public class ProcessInfo {

    private int pid;               // 进程ID
    private String name;           // 进程名称
    private String commandLine;    // 启动命令行
    private String user;           // 进程所属用户
    private double cpuUsage;       // CPU使用率（%）
    private long memoryUsage;      // 内存占用（字节）
    private long startTime;        // 启动时间（毫秒时间戳）
    private long upTime;           // 运行时间（毫秒）


    public DbProcessInfo toDbProcessInfo() {
        DbProcessInfo dbProcessInfo = new DbProcessInfo();
        dbProcessInfo.setPid(String.valueOf(pid));
        dbProcessInfo.setName(name);
        dbProcessInfo.setCommandLine(commandLine);
        dbProcessInfo.setUser(user);
        dbProcessInfo.setCpuUsage(String.valueOf(cpuUsage));
        dbProcessInfo.setMemoryUsage(String.valueOf(memoryUsage));
        dbProcessInfo.setStartTime(String.valueOf(startTime));
        dbProcessInfo.setUpTime(String.valueOf(upTime));
        return dbProcessInfo;
    }

}
